package com.hsshy.beam.excel.controller;

import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.metadata.Sheet;
import com.hsshy.beam.excel.domain.Model;
import com.hsshy.beam.excel.listener.ExportInfoListener;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

/**
 * @description: 读取Excel
 * @author: hs
 * @create: 2019-06-05 16:04:15
 **/
@Api(value = "ReadExcelController")
@RestController
@RequestMapping(value = "/read")
public class ReadExcelController {

    @ApiOperation(value = "读ExportInfo")
    @PostMapping(value = "/exportInfo")
    public void readExportInfo(@RequestPart MultipartFile file) throws IOException {

        InputStream inputStream = file.getInputStream();
        ExportInfoListener listener = new ExportInfoListener();
        EasyExcelFactory.readBySax(inputStream, new Sheet(1, 1, Model.class),listener);
        inputStream.close();
    }



}
